const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('base_intelligence_details', {
    id: {
      autoIncrement: true,
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: "唯一标识"
    },
    certid: {
      type: DataTypes.STRING(100),
      allowNull: false,
      primaryKey: true,
      comment: "资质证书编号",
      references: {
        model: 'base_enterprise_intelligence',
        key: 'certid'
      }
    },
    tradetypenum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "资质序列代码"
    },
    tradeboundnum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "专业类别代码"
    },
    titleLeveinum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "资质等级代码"
    },
    ismaster: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "是否主项资质"
    },
    mark: {
      type: DataTypes.STRING(500),
      allowNull: true,
      comment: "批准资质内容"
    },
    notenumber: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: "首次批准资质文号"
    },
    notedate: {
      type: DataTypes.DATEONLY,
      allowNull: true,
      comment: "首次批准资质日期"
    },
    addtypenum: {
      type: DataTypes.STRING(3),
      allowNull: true,
      comment: "资质取得方式代码"
    },
    certtradestatusnum: {
      type: DataTypes.STRING(3),
      allowNull: true,
      comment: "资质状态代码"
    },
    isDeleted: {
      type: DataTypes.TINYINT,
      allowNull: true,
      comment: "是否删除",
      field: 'is_deleted'
    },
    createdUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "创建人",
      field: 'created_user'
    },
    createdTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "本系统创建时间",
      field: 'created_time'
    },
    updatedUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "修改人",
      field: 'updated_user'
    },
    updatedTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "修改时间",
      field: 'updated_time'
    }
  }, {
    sequelize,
    tableName: 'base_intelligence_details',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
          { name: "certid" },
        ]
      },
      {
        name: "fk_base_intelligence_details",
        using: "BTREE",
        fields: [
          { name: "certid" },
        ]
      },
    ]
  });
};
